<table>
	<tr><th rowspan="2">Title</th><th colspan="2">Authors</th><th rowspan="2">Abstract</th></tr>
	<tr><th>usernames</th><th>names</th></tr>
										
	<?php
	
	$stmtBib = DBExecute("	SELECT id as bibtexid, title, abstract FROM
							BIBTEX "); //TODO where it is an uploaded paper! 
	
	
	while($rowBib = $stmtBib->fetchAssocRow()) { 
		?>
		<tr><td><a href="paper_view.php?id=<?php echo $rowBib['BIBTEXID']; ?>"><span class="title"><?php echo (empty($rowBib['TITLE'])) ? "Paper ".$rowBib['BIBTEXID'] : $rowBib['TITLE']; ?></span></a></td>							
		<?php
			$stmtAuth = DBExecute("	SELECT distinct username,name,p.id as id FROM
						AUTHORING a, RESOURCE r, Person p 
						WHERE 
						r.bibtexid = ? AND a.resourceid = r.id 
						AND a.personid = p.id ", $rowBib['BIBTEXID']);
			
			$authNames = "";
			$authUsr = "";
			while($rowAuth = $stmtAuth->fetchAssocRow()){
				$authNames .= $rowAuth['NAME'] . ", ";
				$authUsr .= (($rowAuth['USERNAME'] != null && $rowAuth['USERNAME'] != "") ? 
					("<a href=\"person_view.php?id=".$rowAuth['ID']."\">".$rowAuth['USERNAME']."</a>") : "-") . ", ";
			}
		?>			    
			<td><?php echo $authUsr?></td><td><?php echo $authNames?></td>
			<td><?php echo $rowBib['ABSTRACT']?></td>
		</tr>
	<?php } ?>
	</table>
